Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Composer: require-dev the PHPUnit Polyfills
While generally speaking, the
require-dev
for PHPUnit should now be removed, I'm leaving it in place due to the PHPUnit >= 9.3.0 issue with PHP-Parser backfilling tokens.If/when that issue is resolved in the future, the direct requirement for PHPUnit can be removed.
Tests: update the bootstrap file
... to always check that a
composer install
has been run and to load the PHPUnit Polyfill autoloader directly when running PHPUnit via a Phar file as the Polyfill library needs to be installed and its autoload file loaded for the tests to work correctly.Tests: add abstract PolyfilledTestCase
This test case extends the
UtilityMethodTestCase
from which most test classes extend and makes both the PHPCSUtils nativeAssertAttributeSame
polyfill, as well as all polyfills from the PHPUnit Polyfill library available.For test classes which don't need the set up and tear down methods contained in the
UtilityMethodTestCase
and would therefore normally extend the PHPUnit nativeTestCase
, the PHPUnit PolyfillYoast\PHPUnitPolyfills\TestCases\XTestCase
can be extended instead.Alternatively, such a test class can just
use
any of the polyfill traits from the PHPUnit Polyfill library directly.Test classes which don't need the polyfilled assertion/expectation methods, can - and should - still just extend the PHPUnit native
TestCase
or the PHPCSUtilsUtilityMethodTestCase
directly.Note: The list of included polyfill traits should be reviewed after each new (major/minor) release of the PHPUnit Polyfill library.
Tests: remove PHPUnit cross-version work-arounds
... in favour of using the PHPUnit Polyfills.